#ifndef LOGINDIALOG_H
#define LOGINDIALOG_H

#include <QDialog>
#include <QMutex>

class QTcpSocket;
class QHostAddress;
class AutoLoginThread;
class CreateUserDialog;

namespace Ui {
class LoginDialog;
}

class LoginDialog : public QDialog
{
    Q_OBJECT

public:
    explicit LoginDialog(QWidget *parent = nullptr);
    ~LoginDialog();

private:
    QTcpSocket *loginSocket=nullptr;        //socket
    quint16 loginPort=8888;                 //服务器端口
    QString strAddress="43.155.134.125";    //服务器ipv4地址

    //注册表
    bool m_autoLogin=false;                //是否自动登录
    bool m_save=false;                     //是否被保存
    int m_user;
    QString m_pswd;

    AutoLoginThread *autoLoginThread=nullptr;   //自动登录
    CreateUserDialog *createUserDialog=nullptr;//注册用户

    Ui::LoginDialog *ui;
    QPoint m_dPosion;//相对位置差
    bool m_moving=false;//是否移动状态
    //
    QMutex mutex;
    // int encrypt(const int &num);            //加密算法-账号id
    QString encrypt(const QString&str);     //加密算法-密码
    void readSettings();
    void writeSetting();
    // QWidget interface
protected:
    virtual void mousePressEvent(QMouseEvent *event) override;
    virtual void mouseMoveEvent(QMouseEvent *event) override;
    virtual void mouseReleaseEvent(QMouseEvent *event) override;
private slots:
    void on_btnLogin_clicked();
    void on_btnMiniSize_clicked();
    void do_connected();
    void do_readyRead();
    void do_autoLoginThread_TimeRun();
    void on_btnCreate_clicked();
    void on_btnModifyPSWD_clicked();
    void on_btnFindPSWD_clicked();
};



#endif // LOGINDIALOG_H
